home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / ByteArray.h < prev    next >
C/C++ Source or Header  |  1992-04-27  |  1KB  |  55 lines

  1. #ifndef ByteArray_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define ByteArray_First
  7.  
  8. #include "Object.h"
  9.  
  10. //---- class ByteArray ---------------------------------------------------------
  11. extern char *cAtPutName;
  12. extern char *cOutOfBoundsError;
  13.  
  14. class ByteArray: public Object {
  15.     byte *cont;
  16.     int  cap;
  17.  
  18.     void AllocByteArray(byte *aStr, int l= -1);
  19.     
  20. public:
  21.     MetaDef(ByteArray);
  22.  
  23.     //---- creation, destruction  
  24.     ByteArray(int size);              
  25.     ByteArray(byte *aStr, int l= -1);               
  26.     ByteArray(char *aStr, int l= -1);               
  27.     ~ByteArray();
  28.  
  29.     //---- accessing
  30.     byte *Str ()
  31.     { return cont; }
  32.     char *CharStr ()
  33.     { return (char*)cont; }
  34.     void SetString (byte *s); 
  35.     void operator= (byte *s);
  36.     char At(int i)
  37.     { return cont[i]; }
  38.     void AtPut(int i, byte c)
  39.     { if ( i < 0 || i >= cap)
  40.         Error(cAtPutName, cOutOfBoundsError);
  41.       else
  42.         cont[i]= c; 
  43.     }
  44.  
  45.     //---- standard overriden methods   
  46.     unsigned long Hash ();
  47.     bool IsEqual (Object*);
  48.     int Compare (Object*);
  49.     OStream& PrintOn(OStream&);
  50.     IStream& ReadFrom(IStream&);
  51.     void InspectorId(char *buf, int sz);
  52. };
  53.  
  54. #endif
  55.